var ApiFactory = require('lib/ApiFactory')

module.exports.saveWidgetApi = ApiFactory({
  url:function(params){
    return BlueWare.urlPrefix+'/dashboard/'+params.dashboardId+'/widget'
  },
  method:'post',
  optionParams:['dashboardId'],
  params:{
    csrf_token:{
      defaultValue:BlueWare['CSRFTOKEN']
    },
    dashboardId:{
      validate:function(val){
        if(!val){
          return '必须选择一个仪表盘'
        }
      }
    },
    name:{
      validate:function(val,model){
        if(!val){
          return '请输入图表标题'
        }
        if(val.length>50){
          return '图表标题不得超过50个字符'
        }
      }
    }
  }
})
